package pl.freetimetool.service;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import pl.freetimetool.dao.HolidayRequestDao;
import pl.freetimetool.domain.Account;
import pl.freetimetool.domain.HolidayRequest;

@Transactional
@Repository
public class HolidayRequestServiceImpl implements HolidayRequestService {

	@Autowired
	HolidayRequestDao holidayRequestDao;

	public void addHolidayRequest(final HolidayRequest holidayRequest) {

		this.holidayRequestDao.addHolidayRequest(holidayRequest);
	}

	public void removeHolidayRequest(final Integer holidayRequestId) {
		this.holidayRequestDao.deleteHolidayRequest(holidayRequestId);

	}

	@Transactional(readOnly = true)
	public HolidayRequest getHolidayRequest(final Integer holidayRequestId) {
		return this.holidayRequestDao.findHolidayRequest(holidayRequestId);
	}

	@Transactional(readOnly = true)
	public Collection<HolidayRequest> getHolidayRequestsList(final Account account) {

		return this.holidayRequestDao.listHolidayRequests(account);

	}

	public List<HolidayRequest> findAllHolidayRequests() {
		return this.holidayRequestDao.findAllHolidayRequest();
	}
}
